'use strict';
/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  /**
   * 后台管理
   */
  router.post('/api/upload/file', controller.uploadcos.file);
  router.post('/wx/upload/file', controller.uploadcos.file);

  /**
   * 用户权限相关
   */
  router.get('/api/dept/list', controller.dept.allList);
  router.resources('dept', '/api/dept', controller.dept);
  router.post('/api/user/login', controller.user.login);
  router.post('/api/user/updateUserRoles', controller.user.updateUserRoles);
  router.get('/api/user/getUserRoles', controller.user.getUserRoles);
  router.get('/api/user/getUserInfo', controller.user.getUserInfo);
  router.resources('user', '/api/user', controller.user);
  router.get('/api/role/list', controller.role.allList);
  router.resources('role', '/api/role', controller.role);
  router.get('/api/menu/list', controller.menu.allList);
  router.resources('menu', '/api/menu', controller.menu);

  /**
   * 业务代码
   */
  // 轮播图
  router.get('/wx/wxBanner/list', controller.wxBanner.allList);
  router.get('/api/wxBanner/list', controller.wxBanner.allList);
  router.resources('wxBanner', '/api/wxBanner', controller.wxBanner);
  // 新闻
  router.get('/wx/wxNews/list', controller.wxNews.allList);
  router.get('/api/wxNews/list', controller.wxNews.allList);
  router.resources('wxNews', '/api/wxNews', controller.wxNews);
  // policy
  router.get('/wx/policy/list', controller.policy.allList);
  router.get('/api/policy/list', controller.policy.allList);
  router.resources('policy', '/api/policy', controller.policy);
  router.resources('policyWx', '/wx/policy', controller.policy);

  /**
   * 课程管理
   */
  // 课程基础信息
  router.get('/wx/course/list', controller.course.allList);
  router.resources('courseWx', '/wx/course', controller.courseWx);
  router.get('/api/course/list', controller.course.allList);
  router.resources('course', '/api/course', controller.course);

  // 课程报名记录
  router.get('/api/courseRecord/list', controller.courseRecord.allList);
  router.post('/api/courseRecord/cancel/:id', controller.courseRecord.cancel);
  router.get('/api/courseRecord/export', controller.courseRecord.exportExcel);
  router.get('/wx/courseRecord/list', controller.courseRecord.allList);
  router.post('/wx/courseRecord/cancel/:id', controller.courseRecord.cancel);
  router.resources('courseRecord', '/api/courseRecord', controller.courseRecord);
  router.resources('courseRecordWx', '/wx/courseRecord', controller.courseRecord);

  /**
   * 家长相关接口
   */
  // 孩子相关
  router.get('/wx/parent/children', controller.parent.getChildren);
  router.get('/api/parent/child/courses', controller.parent.getChildCourses);
  // 基础接口（使用base的增删改查）
  router.get('/api/parent/list', controller.parent.allList);
  router.resources('parent', '/api/parent', controller.parent);
  router.resources('parentWx', '/wx/parent', controller.parent);
  // 微信登录
  router.post('/wx/parent/wx-login', controller.parent.wxLogin);

  /**
   * 学生相关接口
   */
  // 基础接口（使用base的增删改查）
  router.resources('student', '/api/student', controller.student);
  // // 特殊查询
  // router.get('/api/student/no/:student_no', controller.student.findByStudentNo);
  router.get('/wx/getClassList', controller.student.getClassList);
  // // 批量操作
  router.post('/api/student/batchCreate', controller.student.bulkCreateOrUpdate);
  router.post('/api/student/deleteAll', controller.student.deleteAll);
  router.post('/wx/bindStudentParent', controller.student.bindStudentParent);
  router.post('/wx/unbindStudentParent', controller.student.unbindStudentParent);

};
